package com.atguigu.netty.inboundhandlerlearndoutboundhandler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * @author: 叶子
 * @date: 2022/03/30 20:12
 **/
public class MyClientInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
//        加入出栈的handler，对数据进行编码
        pipeline.addLast(new MyLongToByteEncoder());
        //这时一个入栈的解码器(入栈的handler)
        pipeline.addLast(new MyByteToLongDecoder());
//        加入自定义的handler，处理业务
        pipeline.addLast(new MyClientHandler());
    }
}